package org.nbict.iot.task.once.charge;

import org.nbict.iot.Pair;
import org.nbict.iot.task.once.Pointer;
import org.nbict.iot.task.once.Status;
import org.nbict.iot.task.once.TimeSpanWindow;

/**
 * Created by songseven on 18/6/22.
 */
public enum ChargeStatus implements Status {

    /**
     * 当前充电状态
     */
    CHARGING {
        @Override
        public void judge(TimeSpanWindow window, Pointer coming) {
            Pointer current = window.current();
            //未充电或者充电完成
            if (coming.charged() == UNCHARGED || coming.charged() == DONE) {
                //充电完成
                //Pointer end = new Pointer(current.vin(), current.);
                window.chargeHolder().add(new Pair<>(window.charging(), coming));
            }
        }
    },
    /**
     * 当前未充电状态
     */
    UNCHARGED {
        @Override
        public void judge(TimeSpanWindow window, Pointer coming) {
            if (coming.charged() == CHARGING) {
                //开始充电
                window.setCharging(coming);
            }
        }
    },
    DONE {
        @Override
        public void judge(TimeSpanWindow window, Pointer coming) {
            if (coming.charged() == CHARGING) {
                //开始充电
                window.setCharging(coming);
            }
        }
    };


    @Override
    public void judge(TimeSpanWindow window, Pointer pointer) {
        //do nothing
    }
}
